/**
 * WTF Engine
 *
 * License... etc.
 **
 * Callbacks
 * @file src/callback.h
 **
 * Author: Sean Micklethwaite
 **/

#ifndef __callbackH__
#define __callbackH__

#include "dynamic.h"
#include "work.h"
#include "functor.h"

namespace WtfEngine {
	
	/**
	 * Callbacks are designed to wrap operations which are to executed in the background,
	 * which take a relatively long time (e.g. loading a file, connecting a socket). The
	 * operation can be any work item, and the callback routine is a functor.
	 * 
	 * Callbacks are 'fire and forget' objects, so calling "new Callback(..)" initializes
	 * everything, then everything is cleaned up once the callback has fired.
	 **/
	class Callback: public virtual IDynamic, public GcObject {
		IWorkItem::tRef	mrWorkItem;
		Functor::tRef	mrFunctor;
		
		public:
			Callback(const IWorkItem::tRef& rWorkItem, const Functor::tRef& rFunctor);
			~Callback();
			
			void Update();
	};
};

#endif
